﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DoAn1
{
    public partial class fileInfo : Form
    {
        public fileInfo()
        {
            InitializeComponent();
        }
        public static string path;
        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FileInfo_Load(object sender, EventArgs e)
        {
            FileInfo file = new FileInfo(path);
            DirectoryInfo dInfo = new DirectoryInfo(path);
            lbl_name.Text = file.Name;
            lbl_location.Text = file.FullName;
            lbl_size.Text = GetDirectorySize(path);
            lbl_create.Text = file.CreationTime.ToString();
            lbl_modify.Text = file.LastWriteTime.ToString();

        }
        private string GetDirectorySize(string path)
        {
            DirectoryInfo info = new DirectoryInfo(path);
            long size = 0;
            try
            {
                foreach (string file in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories))
                {
                    size += new FileInfo(file).Length;
                }
            }
            catch (Exception) { }
            return Math.Round((double)size / (double)(1024 * 1024), 2).ToString() + " MB";
        }
    }
}
